<?php
$control->renderView('weChatShare');
//获取当前user信息
$userCooker = new BAUserCooker();
$userInfo = $userCooker->getUserInfo();
//var_dump($userInfo);
$familyNameAttr = '';
$surNameAttr = '';
if ($userInfo->getItem('familyName') != NULL)
    $familyNameAttr = $userInfo->getItem('familyName')->getValue();
if ($userInfo->getItem('surName') != NULL)
    $surNameAttr = $userInfo->getItem('surName')->getValue();
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/wei_webapp_new.css' ?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/wei_dialog.css' ?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/common.css' ?>">

<!-- ajax加载页面时弹出加载旋转gif图 -->
<style>
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="<?php echo Yii::app()->request->baseUrl . '/images/ajax-loader.gif' ?>" class="ajax-loader">
</div>


<div id="page_card" class="div-body">

    <div id="mappContainer">
        <div class="inner root" style="height: 519px;">
            <div class="card" style="-webkit-background-size:267px 159px;background-size:267px 159px;box-shadow: none;height: 40px;" data-card-type="0">
            </div>
            <?php if (!isset($applyView) || $applyView == NULL) { ?>

                <p><span style="padding-left: 0px;background-size: 0px;">您已经领取了所有的代金券，谢谢！您可以通过以下链接查看您的代金券：</span></p>
                <?php
                echo $control->getAjaxLink('我的代金券', array(
                    'cooker' => 'BAVoucher@showUserVoucherListInMobile',
                    'htmlOptions' => array('class' => 'btn btn-warning')
                ));
                ?>

                <?php
                return;
            }
            ?>
            <p><span>可以领取的代金券有(点击领取)：</span></p>
            <?php
            $voucherCooker = new BAVoucherCooker();
            $permitCooker = new BAPermitCooker();
            foreach ($applyView as $id => $lastChangeTime) {
                $permit = $permitCooker->getPermit($id);
                $typeId = $permit->getItem('voucherTypeId')->getValue();
                $voucherType = $voucherCooker->getVoucherType($typeId);
                $voucherTypeAlias = $voucherType->getValue();
                $permitName = $permit->getItem('permit')->getValue();
                $permitAlias = BAVoucherCooker::getPermitAlias($permitName);
                if ($permitName == BAVoucherCooker::Permit_Allow_Add) {
                    $aLink = $control->getAjaxScript('领取', array(
                        'cooker' => 'BAVoucher@showUserAddVoucher',
                        'voucherTypeId' => $typeId,
                        'permitId' => $id
                    ));
                }
                if ($permitName == BAVoucherCooker::Permit_Allow_Approve) {
                    $aLink = $control->getAjaxScript('申请', array(
                        'cooker' => 'BAVoucher@showUserApplyVoucher',
                        'voucherTypeId' => $typeId,
                        'permitId' => $id
                    ));
                }
                ?>
                <li style="margin-bottom: 10px;margin-top: 10px;" onclick ="<?php echo $aLink; ?>">
                    <div class="card" style="-webkit-background-size:267px 159px;height: 50px;width: 100%;" data-card-type="0">
                        <strong class="pdo verify" style="top: 10px;">
                            <span style="color:#92714e;text-shadow:0 1px #f1e7dc;float: left;margin-left: 10px;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">代金券类型</em><?php echo $voucherTypeAlias; ?></span>
                            <span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">券号</em><?php echo $typeId; ?></span>
                        </strong>
                    </div>
                </li>
            <?php } ?>
        </div>
        <?php
        $returnUrl = $control->getAjaxScript('返回会员卡页', array(
            'cooker' => 'BAMemberCard@showUserCardHome',
        ));
        ?>
        <?php if (!isset($applyView) || $applyView == NULL) { ?>
            <div class = "footFix" id = "footReturn"><a href = "javascript:void(0)" onclick = "<?php echo $returnUrl; ?>"><span>返回会员卡页</span></a></div>
        <?php }
        ?>
        <div class="footFix" id="footReturn"><a  href="javascript:void(0)" onclick="<?php echo $returnUrl; ?>"><span>返回会员卡页</span></a></div>
    </div>

<!--    <div id="mCopyright">
        <div class="mcrInn">
            <h1>比邻平台</h1>
        </div>
    </div>-->

</div>
